/**
 * Created by DELL on 2017/5/11.
 */
var houseId=common.getQueryString("houseId");
buildSelect.buildEmployeeList("#contact");
$("#houseId").val(houseId);
var $form=$("form");
var validateResult=$form.validate({
    /**
     * ignore：忽略某些元素不验证
     * @type {String}
     * 例如：ignore: ".ignore" ，忽略所有的带ignore class 的标签
     */
    ignore: ".ignore"
});
window.formObject = $form;
var userInfo=common.getLocalData(common.agentSysCacheWord).user;
var record = {
    coverPhoto:"",
    housePhotos:""
};
var coverPhotoGallery=$("#cover-photo").gallery({
    // readOnly:record.saleStatus==="SOLD",
    readOnly:false,
    title:"上传悬赏房源封面",
    url:window.globalHost +common.uploadImagePort,
    paramName:"uploadData",
    fileFolder:{folder:"house",id:userInfo.id,fileName:"sys_esheyiHouse_"+new Date().getTime()},
    returnPathName:"filePath",
    maxFiles:1,
    filePaths:record.coverPhoto?[record.coverPhoto]:[],
    uploadCallback:function () {
        var path=coverPhotoGallery.getFilePaths();
        $("#coverPhoto").val(!!path.length?path.join(","):"")
    },
    deleteCallback:function () {
        var path=coverPhotoGallery.getFilePaths();
        $("#coverPhoto").val(!!path.length?path.join(","):"");
    }
});
var salePhotosGallery=$("#reward-photos").gallery({
    // readOnly:record.saleStatus==="SOLD",
    readOnly:false,
    title:"上传悬赏房源图片",
    url:window.globalHost + common.uploadImagePort,
    paramName:"uploadData",
    fileFolder:{folder:"house",id:userInfo.id,fileName:"sys_esheyiHouse_"+new Date().getTime()},
    returnPathName:"filePath",
    maxFiles:20,
    filePaths:record.housePhotos?record.housePhotos.split(","):[],
    uploadCallback:function () {
        var path=salePhotosGallery.getFilePaths();
        $("#housePhotos").val(!!path.length?path.join(","):"")
    },
    deleteCallback:function () {
        var path=salePhotosGallery.getFilePaths();
        $("#housePhotos").val(!!path.length?path.join(","):"");
    }
});